/*
 * bsp_script.h
 *
 * Copyright (C) 2011 - Dr.NP
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 */

#ifndef BSP_SCRIPT_H

#define BSP_SCRIPT_H                            1

#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

// Definations
#define SCRIPT_LIST_INITIAL                     256
#define MAX_SCRIPT_FILENAME_LENGTH              1024

// Macros

// Structs
struct script_t
{
    int id;
    char script_filename[MAX_SCRIPT_FILENAME_LENGTH];
    int load_time;
    int load_times;
    char is_loaded;
    char in_use;
    char is_conf;

    lua_State *main_state;                      // We have LUA only now... I hate python... >_<!
    lua_State **worker_states;
    int nwstates;
};

// Functions
int script_init(int);
int new_script();
int del_script(struct script_t *);
struct script_t * get_script(int);
int load_script(struct script_t *, const char *);
int unload_script(struct script_t *);
int script_reg_funcs(struct script_t *, const luaL_Reg *);

void clear_stack(lua_State *);
void dump_stack(lua_State *);

#endif  /* bsp_script.h */
